-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Egress Traffic Tracking + Stripe Billing Meters #430
Conversation
afffed6
to
5f86e7d
Compare
2194d13
to
8ed550e
Compare
c389ce8
to
f692f12
Compare
77cd722
to
b8275dd
Compare
b8275dd
to
c5223d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few changes needed and some TODOs that need to be addressed but generally great stuff! excited to use the new billing meters!
1e1a786
to
a12d35e
Compare
0cd043e
to
68f0a49
Compare
View stack outputs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM with one big comment:
I don't think we will have the customer DID when we call usage/record in freeway. @Peeja can you confirm that I'm right on that? Or maybe @travis has more context.
I'm sorry I didn't catch this earlier. You should be able to look it up via the subscription for the space.
Thanks for the review. No problem. That's right @hannahhoward , we won't have the Customer DID in the Freeway project, but we will have the Space DID, and this is what we will pass in the invocation. The w3up project was updated to derive the Customer DID from the Space+Provider: https://github.com/storacha/w3up/blob/main/packages/upload-api/src/usage/record.js#L18, and then it pushes the event to the queue with the Customer DID expected in the w3infra. |
Perfect block removed |
Most of the suggested changes were implemented.
Egress Traffic Tracking and Stripe Billing Meters API Integration
This PR introduces an asynchronous solution for tracking egress traffic in the Freeway Gateway and reporting events to Stripe’s Billing Meters API.
RFC Reference
Storacha Network is implementing a scalable, automated mechanism for tracking egress traffic and updating Stripe’s API with relevant data to ensure accurate customer billing. This RFC outlines the proposed approaches and their trade-offs.
Implementation
The selected approach for this implementation is Alternative 3:
usage/record
, SQS, Lambda with Stripe IntegrationFlow
usage/record
capability usingctx.waitUntil
.w3infra/upload-api/stores/usage.js
receives the events from the Kinesis stream and places the egress data into an Egress Traffic SQS queue.Key Advantages
ctx.waitUntil
ensures the Freeway Worker won’t block, allowing seamless egress traffic handling.Summary of Changes
usage/record
capability handler inw3infra/upload-api/stores/usage.js
to handle egress data from the Kinesis stream and place them into the SQS queue.Next Steps